package com.zhao.fishingguideserver.mapper;

import com.zhao.fishingguideserver.POJO.Cart;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface CartMapper {
    Cart selectByUserIdAndProductId(@Param("userId") Long userId, @Param("productId") Long productId);

    List<Cart> selectByUserId(@Param("userId") Long userId);

    int updateBatchById(@Param("list") List<Cart> list);

    int insert(Cart record);

    int updateById(Cart record);

    Cart selectById(Long cartId);

    int deleteById(Long cartId);

    int deleteBatchIds(@Param("cartIds") List<Long> cartIds);
    
    /**
     * 根据商品ID删除所有购物车记录（订单创建时调用）
     */
    int deleteByProductId(@Param("productId") Long productId);
}
